using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Jbe.TestSuite.Infrastructure.Interface;
using Jbe.TestSuite.TestDevice.Manager;
using Jbe.CABExtension.UnitTest;
using Jbe.CABExtension.UnitTest.Mocks;
using Microsoft.Practices.CompositeUI.UIElements;
using Microsoft.Practices.CompositeUI.Commands;
using Jbe.TestSuite.TestDevice.Manager.Constants;
using System.Windows.Forms;
using Jbe.TestSuite.TestDevice.Manager.Interface.Services;

namespace Jbe.TestSuite.TestDevice.Manager.Tests
{
    /// <summary>
    /// Summary description for ModuleControllerTestFixture
    /// </summary>
    [TestClass]
    public class ModuleControllerTestFixture : FixtureBase
    {
        private ControlledWorkItem<ModuleController> workItem;

        [TestInitialize]
        public override void TestInitialize()
        {
            base.TestInitialize();
            
            workItem = rootWorkItem.WorkItems.AddNew<ControlledWorkItem<ModuleController>>();
            workItem.Controller.Run();
        }

        [TestMethod]
        public void ModuleControllerRegistersService()
        {
            Assert.IsNotNull(workItem.Services.Get(typeof(ITestDeviceManager), false));
        }

        [TestMethod]
        public void ModuleControllerRegistersUIElementAdapter()
        {
            // Check if the ModuleController registers one UIElement
            Assert.AreEqual(1, viewMenuItemAdapter.UIElements.Count, "UIElements");
        }

        [TestMethod]
        public void ModuleControllerShowsSmartPart()
        {
            // Check if the smart part is added
            Assert.AreEqual(1, workItem.SmartParts.Count, "SmartParts");

            // Check if the smart part is shown
            Assert.IsNotNull(dockPanelWorkspace.ShownSmartPart);
        }
    }
}
